/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bda.mediatheque.service;

import com.bda.mediatheque.entities.Utilisateur;
import java.util.List;
import javax.persistence.Query;

/**
 *
 * @author samsung
 */
public class ImplUtilisateurDao extends ImplJpaDao<Integer, Utilisateur> implements IUtilisateurDao{
 
    /*
     * This function is used during the login action to look for the user by its login.
     */
    @Override
    public Utilisateur findUserByLogin(String login)
    {
      try
      {
        Query query = (Query) entityManager.createQuery("select u from Utilisateur u where u.login = :login");  
        query.setParameter("login", login);
        
        return (Utilisateur) query.getSingleResult();
      } catch (Exception exp) {
          exp.printStackTrace();
          // to do : Add log tool to the project.
          return null;
      }
    }
}
